package com.lnu.information.set;

import java.util.HashSet;
import java.util.Iterator;

/**
 * @author : jian.zhang-2
 * @description:
 * @date : Create in 2:18 PM 2022/4/30
 * @modified By :
 */
public class SetProcess {
    public static void main(String[] args) {
        HashSet<Integer> a = new HashSet<>();
        HashSet<Integer> b = new HashSet<>();
        for(int i = 1; i <= 4 ; i++){
            a.add(i);
        }
        b.add(1);
        b.add(2);
        b.add(5);
        b.add(6);
        HashSet<Integer> tempSet = (HashSet<Integer>)a.clone();
        a.removeAll(b);
        b.removeAll(tempSet);
        b.addAll(a);
        System.out.println("a和b的对称差的集合有" + b.size() + "个元素");
        Iterator<?> iter = b.iterator();
        while (iter.hasNext()){
            System.out.println(iter.next());
        }
    }
}
